package com.oracle.manager.web;

import com.oracle.beans.CheckGroupData;
import com.oracle.beans.QueryPageVo;
import com.oracle.beans.ResultInfo;
import com.oracle.manager.service.feign.CheckGroupFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/manager/checkGroup")
@Slf4j
public class CheckGroupController {

    @Autowired
    CheckGroupFeignClient checkGroupFeignClient;

    @GetMapping("findList")
    public ResultInfo findList(QueryPageVo vo){
        //todo 调用服提供方的功能查询检查组
        ResultInfo resultInfo = checkGroupFeignClient.findList(vo.getCurrentPage(),
                vo.getPageSize(),vo.getQueryString());
        return resultInfo;
    }
    @PostMapping("add")
    public ResultInfo add(@RequestBody CheckGroupData checkGroupData){
        //todo 远程调用服务提供方功能进行添加
        ResultInfo resultInfo=checkGroupFeignClient.add(checkGroupData);
        return resultInfo;
    }

    @GetMapping("checkItem/{id}")
    public ResultInfo findCheckGroupItems(@PathVariable("id") Integer id){
        //todo 远程调用服务提供方的功能获取检查组关联的检查项id集合
        ResultInfo resultInfo = checkGroupFeignClient.findCheckItemIds(id);
        return resultInfo;
    }
    @PutMapping("update")
    public ResultInfo update(@RequestBody CheckGroupData checkGroupData){
        log.warn(checkGroupData.toString());
        ResultInfo resultInfo=checkGroupFeignClient.update(checkGroupData);
        return resultInfo;
    }
    @DeleteMapping("detele/{id}")
    public ResultInfo delete(@PathVariable("id") Integer id){
        ResultInfo resultInfo=checkGroupFeignClient.delete(id);
        return resultInfo;
    }
}
